import React from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import "./App.scss";
import Layout from "./pages/Layout";
import Login from "./pages/Login";

function App() {
  return (
    <div className="app">
      {/* 定义路由规则 */}
      {/* <Route path={'/'} exact>
        <Redirect to={'/home'}></Redirect>
      </Route>
      
      <Route path={'/'} exact render={() => {
        // 路径匹配到之后，可以执行一些复杂的逻辑判断，并决定最后要渲染什么内容
        return <Redirect to={'/home'}></Redirect>
      }}></Route> */}

      <Switch>
        <Redirect path={"/"} exact to={"/home"}></Redirect>

        <Route path={"/home"} exact component={Layout}></Route>

        <Route path={"/login"} exact component={Login}></Route>
      </Switch>
    </div>
  );
}

export default App;
